package com.itheima.ydd.controller;


import com.itheima.ydd.common.R;
import com.itheima.ydd.common.ResultData;
import com.itheima.ydd.entity.YddAdvpos;
import com.itheima.ydd.service.IYddAdvimgService;
import com.itheima.ydd.service.IYddAdvposService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2022-05-22
 */
@RestController
@RequestMapping("/ydd_advpos")
public class YddAdvposController {
    @Autowired
    private IYddAdvposService yddAdvposService;


    @GetMapping("/list")
    public ResultData selectByPage(String advposname, Integer page, Integer limit){
        ResultData selectByPage = yddAdvposService.selectByPage(advposname,page,limit);
        return selectByPage;
    }

    @PostMapping("/add")
    public R add(@RequestBody YddAdvpos yddAdvpos){
        yddAdvposService.add(yddAdvpos);
        return R.success("200",null);
    }

    //根据id查询
    @GetMapping("/rowInfo")
    public ResultData selectById(Integer id){
        YddAdvpos yddAdvpos = yddAdvposService.selectById(id);
        return ResultData.ok(null,yddAdvpos);
    }

    //修改
    @PostMapping("/update")
    public R update(@RequestBody YddAdvpos yddAdvpos){
        yddAdvposService.updateyddArt(yddAdvpos);
        return R.success("200",null);
    }

    //根据id删除
    @GetMapping("/del")
    public R deleteById(Long id){
        yddAdvposService.removeById(id);
        return R.success("200",null);
    }

    @GetMapping("/all")
    public ResultData selectall(){
        ResultData selectByall = yddAdvposService.selectByselectByall();
        return selectByall;
    }
}
